<template>
  <div class="ranking-container">
    <!-- 动态背景 -->
    <canvas ref="backgroundCanvas" class="background-canvas"></canvas>
    
    <!-- 浮动粒子 -->
    <div class="floating-particles">
      <div class="particle" v-for="n in 25" :key="'particle-' + n"></div>
    </div>
    
    <!-- 光束动画 -->
    <div class="light-beams">
      <div class="beam beam-1"></div>
      <div class="beam beam-2"></div>
      <div class="beam beam-3"></div>
      <div class="beam beam-4"></div>
    </div>

    <!-- 页面头部 -->
    <div class="ranking-header">
      <div class="header-content">
        <h1 class="page-title">
          <i class="fas fa-trophy"></i>
          排行榜
        </h1>
        <div class="header-actions">
          <button @click="$router.back()" class="back-btn">
            <i class="fas fa-arrow-left"></i>
            返回
          </button>
          <button @click="refreshRanking" class="refresh-btn" :disabled="loading">
            <i class="fas fa-sync-alt" :class="{ 'fa-spin': loading }"></i>
            刷新
          </button>
        </div>
      </div>
    </div>

    <div class="ranking-content">
      <!-- 排行榜主要内容 -->
      <div class="ranking-main">
        <!-- 前三名展示 -->
        <div v-if="topThree.length > 0" class="podium-section">
          <div class="podium-container">
            <!-- 第二名 -->
            <div v-if="topThree[1]" class="podium-item podium-second">
              <div class="podium-rank">2</div>
              <div class="podium-avatar">
                <img :src="getAvatarUrl(topThree[1].avatar)" :alt="topThree[1].username">
                <div class="avatar-glow"></div>
              </div>
              <div class="podium-info">
                <div class="podium-username">{{ topThree[1].username }}</div>
                <div class="podium-score">{{ topThree[1].score }}</div>
                <div class="tier-badge" :class="getTierClass(topThree[1].score)">
                  {{ getTierName(topThree[1].score) }}
                </div>
              </div>
            </div>

            <!-- 第一名 -->
            <div v-if="topThree[0]" class="podium-item podium-first">
              <div class="podium-crown">
                <i class="fas fa-crown"></i>
              </div>
              <div class="podium-rank">1</div>
              <div class="podium-avatar">
                <img :src="getAvatarUrl(topThree[0].avatar)" :alt="topThree[0].username">
                <div class="avatar-glow"></div>
              </div>
              <div class="podium-info">
                <div class="podium-username">{{ topThree[0].username }}</div>
                <div class="podium-score">{{ topThree[0].score }}</div>
                <div class="tier-badge" :class="getTierClass(topThree[0].score)">
                  {{ getTierName(topThree[0].score) }}
                </div>
              </div>
            </div>

            <!-- 第三名 -->
            <div v-if="topThree[2]" class="podium-item podium-third">
              <div class="podium-rank">3</div>
              <div class="podium-avatar">
                <img :src="getAvatarUrl(topThree[2].avatar)" :alt="topThree[2].username">
                <div class="avatar-glow"></div>
              </div>
              <div class="podium-info">
                <div class="podium-username">{{ topThree[2].username }}</div>
                <div class="podium-score">{{ topThree[2].score }}</div>
                <div class="tier-badge" :class="getTierClass(topThree[2].score)">
                  {{ getTierName(topThree[2].score) }}
                </div>
              </div>
            </div>
          </div>
        </div>

        <!-- 排行榜列表 -->
        <div class="ranking-list">
          <div class="list-header">
            <h3>
              <i class="fas fa-list-ol"></i>
              {{ getTabLabel(currentTab) }}排行榜
            </h3>
            <div class="list-info">
              显示第 {{ (pagination.current - 1) * pagination.pageSize + 1 }} -
              {{ Math.min(pagination.current * pagination.pageSize, pagination.total) }} 名，
              共 {{ pagination.total }} 名玩家
            </div>
          </div>

          <div v-if="loading" class="loading-state">
            <div class="loading-spinner">
              <div class="loading-rings">
                <div class="loading-ring"></div>
                <div class="loading-ring"></div>
                <div class="loading-ring"></div>
              </div>
              <p>加载中...</p>
            </div>
          </div>

          <div v-else-if="rankings.length === 0" class="empty-state">
            <div class="empty-animation">
              <i class="fas fa-trophy"></i>
              <div class="empty-particles">
                <div class="empty-particle"></div>
                <div class="empty-particle"></div>
                <div class="empty-particle"></div>
              </div>
            </div>
            <p>暂无排行榜数据</p>
          </div>

          <div v-else class="ranking-items">
            <div v-for="(player, index) in rankings" :key="player.id"
              :class="['ranking-item', { 'is-current-user': player.isCurrentUser }]">
              <div class="item-background"></div>
              
              <div class="rank-number">
                <div v-if="player.rank <= 3" class="rank-medal">
                  <i :class="getRankIcon(player.rank)"></i>
                </div>
                <span v-else class="rank-text">{{ player.rank }}</span>
              </div>

              <div class="player-avatar">
                <img :src="getAvatarUrl(player.avatar)" :alt="player.username">
                <div v-if="player.isOnline" class="online-indicator"></div>
                <div class="avatar-border"></div>
              </div>

              <div class="player-info">
                <div class="player-username">
                  {{ player.username }}
                  <i v-if="player.isVip" class="fas fa-crown vip-icon"></i>
                </div>
                <div class="tier-badge" :class="getTierClass(player.score)">
                  {{ getTierName(player.score) }}
                </div>
              </div>

              <div class="player-stats">
                <div class="stat-item">
                  <span class="stat-label">积分</span>
                  <span class="stat-value">{{ player.score }}</span>
                </div>
                <div class="stat-item">
                  <span class="stat-label">胜率</span>
                  <span class="stat-value">{{ player.winRate }}%</span>
                </div>
                <div class="stat-item">
                  <span class="stat-label">场次</span>
                  <span class="stat-value">{{ player.totalGames }}</span>
                </div>
              </div>

              <div class="rank-change">
                <div v-if="player.rankChange > 0" class="rank-up">
                  <i class="fas fa-arrow-up"></i>
                  +{{ player.rankChange }}
                </div>
                <div v-else-if="player.rankChange < 0" class="rank-down">
                  <i class="fas fa-arrow-down"></i>
                  {{ player.rankChange }}
                </div>
                <div v-else class="rank-same">
                  <i class="fas fa-minus"></i>
                </div>
              </div>
            </div>
          </div>

          <!-- 分页器 -->
          <div v-if="pagination.total > pagination.pageSize" class="pagination">
            <button @click="changePage(pagination.current - 1)" :disabled="pagination.current === 1 || loading"
              class="pagination-btn">
              <i class="fas fa-chevron-left"></i>
              上一页
            </button>

            <div class="pagination-pages">
              <button v-for="page in visiblePages" :key="page" @click="changePage(page)"
                :class="['pagination-page', { active: page === pagination.current }]" :disabled="loading">
                {{ page }}
              </button>
            </div>

            <button @click="changePage(pagination.current + 1)" :disabled="pagination.current >= totalPages || loading"
              class="pagination-btn">
              下一页
              <i class="fas fa-chevron-right"></i>
            </button>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, reactive, computed, onMounted, onUnmounted, watch } from 'vue'
import { rankingAPI } from '@/api/ranking.js'
import { useUserStore } from '@/stores/user.js'

// 静态导入所有头像
import avatar1 from '/images/avatar1.png'
import avatar2 from '/images/avatar2.png'
import avatar3 from '/images/avatar3.png'
import avatar4 from '/images/avatar4.png'
import avatar5 from '/images/avatar5.png'
import avatar6 from '/images/avatar6.png'

// 使用用户状态管理
const userStore = useUserStore()

// 背景canvas引用
const backgroundCanvas = ref(null)
let animationId = null
let particles = []

// 初始化动态背景
const initDynamicBackground = () => {
  const canvas = backgroundCanvas.value
  if (!canvas) return
  
  const ctx = canvas.getContext('2d')
  
  // 设置画布大小
  const resizeCanvas = () => {
    canvas.width = window.innerWidth
    canvas.height = window.innerHeight
  }
  
  resizeCanvas()
  window.addEventListener('resize', resizeCanvas)
  
  // 创建粒子系统（专门为排行榜设计）
  const createParticles = () => {
    particles = []
    for (let i = 0; i < 35; i++) {
      particles.push({
        x: Math.random() * canvas.width,
        y: Math.random() * canvas.height,
        size: Math.random() * 2 + 0.5,
        speedX: (Math.random() - 0.5) * 1,
        speedY: (Math.random() - 0.5) * 1,
        opacity: Math.random() * 0.7 + 0.2,
        hue: Math.random() * 60 + 40, // 金色调为主
        life: Math.random() * 100,
        maxTrailLength: Math.floor(Math.random() * 6) + 3,
        trail: [],
        type: Math.random() > 0.8 ? 'trophy' : 'star' // 80%星星，20%奖杯粒子
      })
    }
  }
  
  // 动画循环
  const animate = () => {
    // 清除画布，使用深色渐变背景
    const gradient = ctx.createLinearGradient(0, 0, canvas.width, canvas.height)
    gradient.addColorStop(0, 'rgba(15, 10, 35, 0.15)')
    gradient.addColorStop(0.3, 'rgba(25, 15, 45, 0.1)')
    gradient.addColorStop(0.7, 'rgba(35, 20, 55, 0.1)')
    gradient.addColorStop(1, 'rgba(45, 25, 65, 0.15)')
    
    ctx.fillStyle = gradient
    ctx.fillRect(0, 0, canvas.width, canvas.height)
    
    // 更新和绘制粒子
    particles.forEach((particle, index) => {
      // 根据粒子类型设置不同的运动模式
      if (particle.type === 'trophy') {
        // 奖杯粒子：缓慢上升，带有闪烁效果
        particle.speedY = -0.3 + Math.sin(particle.life * 0.05) * 0.2
        particle.speedX = Math.sin(particle.life * 0.03) * 0.5
        particle.x += particle.speedX
        particle.y += particle.speedY
        particle.opacity = 0.4 + Math.sin(particle.life * 0.08) * 0.3
      } else {
        // 星星粒子：轻微飘动
        particle.speedX += (Math.random() - 0.5) * 0.008
        particle.speedY += (Math.random() - 0.5) * 0.008
        particle.x += particle.speedX * 0.8
        particle.y += particle.speedY * 0.8
      }
      
      // 更新轨迹
      particle.trail.push({
        x: particle.x, 
        y: particle.y,
        time: Date.now()
      })
      
      while (particle.trail.length > particle.maxTrailLength) {
        particle.trail.shift()
      }
      
      particle.life += particle.type === 'trophy' ? 0.4 : 0.2
      
      // 边界处理
      if (particle.type === 'trophy') {
        if (particle.y < -50) {
          particle.y = canvas.height + 50
          particle.x = Math.random() * canvas.width
          particle.trail = []
          particle.life = 0
        }
        if (particle.x < -50 || particle.x > canvas.width + 50) {
          particle.x = Math.random() * canvas.width
        }
      } else {
        // 星星粒子边界反弹
        if (particle.x < 0 || particle.x > canvas.width) {
          particle.speedX *= -0.9
          particle.x = Math.max(0, Math.min(canvas.width, particle.x))
        }
        if (particle.y < 0 || particle.y > canvas.height) {
          particle.speedY *= -0.9
          particle.y = Math.max(0, Math.min(canvas.height, particle.y))
        }
      }
      
      // 生命周期处理
      if (particle.life > 120) {
        particle.life = 0
        particle.opacity = Math.random() * 0.7 + 0.2
        particle.hue = Math.random() * 60 + 40
      }
      
      // 绘制轨迹（只对奖杯粒子）
      if (particle.trail.length > 2 && particle.type === 'trophy') {
        particle.trail.forEach((point, i) => {
          if (i === particle.trail.length - 1) return
          
          const progress = i / particle.trail.length
          const trailOpacity = progress * particle.opacity * 0.4
          const trailSize = particle.size * (0.2 + progress * 0.8)
          
          ctx.beginPath()
          ctx.arc(point.x, point.y, trailSize, 0, Math.PI * 2)
          ctx.fillStyle = `hsla(${particle.hue}, 80%, 70%, ${trailOpacity})`
          ctx.fill()
        })
      }
      
      // 绘制主粒子
      const pulseIntensity = particle.type === 'trophy' ? 0.6 : 0.3
      const pulseSize = particle.size + Math.sin(particle.life * 0.06) * pulseIntensity
      
      // 主粒子光晕效果
      const glowSize = pulseSize * 3
      const glowGradient = ctx.createRadialGradient(
        particle.x, particle.y, 0,
        particle.x, particle.y, glowSize
      )
      
      if (particle.type === 'trophy') {
        // 奖杯粒子：金色光晕
        glowGradient.addColorStop(0, `hsla(${particle.hue}, 95%, 80%, ${particle.opacity})`)
        glowGradient.addColorStop(0.3, `hsla(${particle.hue}, 85%, 70%, ${particle.opacity * 0.6})`)
        glowGradient.addColorStop(1, `hsla(${particle.hue}, 75%, 60%, 0)`)
      } else {
        // 星星粒子：银白色光晕
        glowGradient.addColorStop(0, `hsla(200, 70%, 90%, ${particle.opacity})`)
        glowGradient.addColorStop(0.4, `hsla(220, 60%, 80%, ${particle.opacity * 0.4})`)
        glowGradient.addColorStop(1, `hsla(240, 50%, 70%, 0)`)
      }
      
      ctx.beginPath()
      ctx.arc(particle.x, particle.y, glowSize, 0, Math.PI * 2)
      ctx.fillStyle = glowGradient
      ctx.fill()
      
      // 主粒子核心
      ctx.beginPath()
      ctx.arc(particle.x, particle.y, pulseSize, 0, Math.PI * 2)
      if (particle.type === 'trophy') {
        ctx.fillStyle = `hsla(${particle.hue}, 100%, 85%, ${particle.opacity})`
      } else {
        ctx.fillStyle = `hsla(200, 80%, 95%, ${particle.opacity})`
      }
      ctx.fill()
      
      // 连线效果（仅星星粒子之间）
      if (particle.type === 'star') {
        particles.forEach((other, otherIndex) => {
          if (index !== otherIndex && other.type === 'star') {
            const dx = particle.x - other.x
            const dy = particle.y - other.y
            const distance = Math.sqrt(dx * dx + dy * dy)
            
            if (distance < 100) {
              const connectionOpacity = (100 - distance) / 100 * 0.1
              ctx.beginPath()
              ctx.moveTo(particle.x, particle.y)
              ctx.lineTo(other.x, other.y)
              ctx.strokeStyle = `hsla(210, 70%, 80%, ${connectionOpacity})`
              ctx.lineWidth = 0.5
              ctx.stroke()
            }
          }
        })
      }
    })
    
    animationId = requestAnimationFrame(animate)
  }
  
  createParticles()
  animate()
}

// 头像映射
const avatarMap = {
  '1': avatar1,
  '2': avatar2,
  '3': avatar3,
  '4': avatar4,
  '5': avatar5,
  '6': avatar6
}

// 获取头像URL的方法
const getAvatarUrl = (avatarUrl) => {
  // 如果没有avatarUrl或为空，使用默认头像
  const avatarNumber = avatarUrl || '1'
  return avatarMap[avatarNumber] || avatar1
}

// 页面状态
const loading = ref(false)
const currentTab = ref('overall')

// 数据
const rankings = ref([])
// 模拟数据（实际开发中应该从API获取）
const mockRankings = [
  {
    id: 1,
    userId: '1',
    username: '玩家1',
    avatar: '1',
    score: 450,
    rank: 1,
    winRate: 85,
    totalGames: 120,
    isCurrentUser: false,
    isOnline: true,
    isVip: true
  },
  {
    id: 2,
    userId: '2',
    username: '玩家2',
    avatar: '2',
    score: 380,
    rank: 2,
    winRate: 78,
    totalGames: 95,
    isCurrentUser: false,
    isOnline: true,
    isVip: false
  },
  {
    id: 3,
    userId: '3',
    username: '玩家3',
    avatar: '3',
    score: 320,
    rank: 3,
    winRate: 72,
    totalGames: 88,
    isCurrentUser: false,
    isOnline: false,
    isVip: false
  },
  {
    id: 4,
    userId: '4',
    username: '玩家4',
    avatar: '4',
    score: 280,
    rank: 4,
    winRate: 68,
    totalGames: 76,
    isCurrentUser: false,
    isOnline: true,
    isVip: false
  },
  {
    id: 5,
    userId: '5',
    username: '玩家5',
    avatar: '5',
    score: 250,
    rank: 5,
    winRate: 65,
    totalGames: 82,
    isCurrentUser: false,
    isOnline: false,
    isVip: false
  }
]

// 分页
const pagination = reactive({
  current: 1,
  pageSize: 20,
  total: 0
})

// 标签配置（仅保留总榜）
const tabs = [
  { key: 'overall', label: '总榜', icon: 'fas fa-globe' }
]

// 计算属性
const topThree = computed(() => {
  return rankings.value.slice(0, 3)
})

const totalPages = computed(() => {
  return Math.ceil(pagination.total / pagination.pageSize)
})

const visiblePages = computed(() => {
  const total = totalPages.value
  const current = pagination.current
  const pages = []

  if (total <= 7) {
    for (let i = 1; i <= total; i++) {
      pages.push(i)
    }
  } else {
    if (current <= 4) {
      for (let i = 1; i <= 5; i++) {
        pages.push(i)
      }
      pages.push('...')
      pages.push(total)
    } else if (current >= total - 3) {
      pages.push(1)
      pages.push('...')
      for (let i = total - 4; i <= total; i++) {
        pages.push(i)
      }
    } else {
      pages.push(1)
      pages.push('...')
      for (let i = current - 1; i <= current + 1; i++) {
        pages.push(i)
      }
      pages.push('...')
      pages.push(total)
    }
  }

  return pages.filter(page => page !== '...' || pages.indexOf(page) === pages.lastIndexOf(page))
})

// 方法
const fetchRankings = async () => {
  try {
    loading.value = true
    const response = await rankingAPI.getOverallRanking(pagination.current, pagination.pageSize)

    if (response && Array.isArray(response)) {
      // 处理API返回的数据
      rankings.value = response.map((item, index) => ({
        id: index + 1,
        userId: item.userId,
        username: item.username || `玩家${index + 1}`,
        avatar: item.avatarUrl || '1',
        score: item.score || 0,
        rank: item.rank || index + 1,
        winRate: item.winRate || 0, // 后端现在提供胜率
        totalGames: item.totalGames || 0, // 后端现在提供场次
        isCurrentUser: item.userId === userStore.userInfo?.id,
        isOnline: Math.random() > 0.3, // 随机在线状态
        isVip: Math.random() > 0.7 // 随机VIP状态
      }))

      // 设置总数（使用实际数据长度）
      pagination.total = response.length
    } else {
      // 如果API没有返回数据，使用模拟数据
      rankings.value = mockRankings
      pagination.total = mockRankings.length
    }

    // 计算前三名
    if (rankings.value.length >= 3) {
      topThree.value = [
        rankings.value[0], // 第一名
        rankings.value[1], // 第二名  
        rankings.value[2]  // 第三名
      ]
    }

    loading.value = false
  } catch (error) {
    console.error('获取排行榜失败:', error)
    // 使用模拟数据作为后备
    rankings.value = mockRankings
    pagination.total = mockRankings.length
    if (rankings.value.length >= 3) {
      topThree.value = [
        rankings.value[0],
        rankings.value[1],
        rankings.value[2]
      ]
    }
    loading.value = false
    showNotification('获取排行榜失败，显示模拟数据', 'warning')
  }
}

// ...existing code...

const changeTab = (tab) => {
  if (tab === currentTab.value) return

  currentTab.value = tab
  pagination.current = 1
  fetchRankings()
}

const changePage = (page) => {
  if (page === '...' || page === pagination.current || loading.value) return

  pagination.current = page
  fetchRankings()
}

const refreshRanking = () => {
  fetchRankings()
}

const getTabLabel = (tab) => {
  const tabMap = {
    overall: '总榜'
  }
  return tabMap[tab] || '总榜'
}

const getRankIcon = (rank) => {
  const iconMap = {
    1: 'fas fa-medal rank-gold',
    2: 'fas fa-medal rank-silver',
    3: 'fas fa-medal rank-bronze'
  }
  return iconMap[rank] || ''
}

const getTierClass = (score) => {
  if (score >= 401) return 'tier-empowered';
  if (score >= 351) return 'tier-mythic';
  if (score >= 301) return 'tier-transcendent';
  if (score >= 251) return 'tier-diamond';
  if (score >= 201) return 'tier-platinum';
  if (score >= 151) return 'tier-gold';
  if (score >= 101) return 'tier-silver';
  if (score >= 51) return 'tier-bronze';
  return 'tier-iron';
};

const getTierName = (score) => {
  if (score >= 401) return '赋能';
  if (score >= 351) return '神话';
  if (score >= 301) return '超凡';
  if (score >= 251) return '钻石';
  if (score >= 201) return '铂金';
  if (score >= 151) return '黄金';
  if (score >= 101) return '白银';
  if (score >= 51) return '青铜';
  return '黑铁';
};

const showNotification = (message, type = 'info') => {
  if (window.$notification) {
    window.$notification[type](message)
  }
}

// ...existing code...

// 生命周期
onMounted(async () => {
  await fetchRankings()
  // 初始化动态背景
  setTimeout(() => {
    initDynamicBackground()
  }, 100)
})

onUnmounted(() => {
  // 清理动画
  if (animationId) {
    cancelAnimationFrame(animationId)
  }
  window.removeEventListener('resize', () => {})
})
</script>

<style scoped>
/* ================ 全局容器样式 ================ */
.ranking-container {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f0a23 0%, #1a0f3a 25%, #2d1b4e 50%, #1e0f3f 75%, #0a0519 100%);
  position: relative;
  overflow-x: hidden;
  color: #fff;
}

/* ================ 动态背景系统 ================ */
.background-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

.floating-particles {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
}

.particle {
  position: absolute;
  width: 3px;
  height: 3px;
  background: radial-gradient(circle, rgba(255, 215, 0, 0.8) 0%, transparent 70%);
  border-radius: 50%;
  animation: particleFloat 12s infinite ease-in-out;
}

.particle:nth-child(odd) {
  animation-duration: 15s;
  background: radial-gradient(circle, rgba(192, 192, 192, 0.6) 0%, transparent 70%);
}

.particle:nth-child(3n) {
  animation-duration: 18s;
  background: radial-gradient(circle, rgba(205, 127, 50, 0.7) 0%, transparent 70%);
}

@keyframes particleFloat {
  0%, 100% {
    transform: translateY(100vh) translateX(0px) scale(0);
    opacity: 0;
  }
  10% {
    opacity: 1;
    transform: translateY(90vh) translateX(15px) scale(1);
  }
  90% {
    opacity: 1;
    transform: translateY(10vh) translateX(-15px) scale(1);
  }
  100% {
    transform: translateY(0vh) translateX(0px) scale(0);
    opacity: 0;
  }
}

.light-beams {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
  pointer-events: none;
}

.beam {
  position: absolute;
  background: linear-gradient(90deg, transparent, rgba(255, 215, 0, 0.1), transparent);
  opacity: 0.3;
}

.beam-1 {
  width: 200%;
  height: 2px;
  top: 15%;
  left: -50%;
  transform: rotate(20deg);
  animation: beamSweep1 14s infinite ease-in-out;
}

.beam-2 {
  width: 150%;
  height: 1px;
  top: 45%;
  left: -25%;
  transform: rotate(-15deg);
  background: linear-gradient(90deg, transparent, rgba(192, 192, 192, 0.15), transparent);
  animation: beamSweep2 18s infinite ease-in-out;
}

.beam-3 {
  width: 180%;
  height: 1px;
  top: 75%;
  left: -40%;
  transform: rotate(10deg);
  background: linear-gradient(90deg, transparent, rgba(205, 127, 50, 0.12), transparent);
  animation: beamSweep3 22s infinite ease-in-out;
}

.beam-4 {
  width: 120%;
  height: 1px;
  top: 85%;
  left: -10%;
  transform: rotate(-5deg);
  background: linear-gradient(90deg, transparent, rgba(255, 215, 0, 0.08), transparent);
  animation: beamSweep4 16s infinite ease-in-out;
}

@keyframes beamSweep1 {
  0%, 100% { transform: translateX(-100%) rotate(20deg); opacity: 0; }
  50% { transform: translateX(100%) rotate(20deg); opacity: 0.3; }
}

@keyframes beamSweep2 {
  0%, 100% { transform: translateX(-100%) rotate(-15deg); opacity: 0; }
  50% { transform: translateX(100%) rotate(-15deg); opacity: 0.4; }
}

@keyframes beamSweep3 {
  0%, 100% { transform: translateX(-100%) rotate(10deg); opacity: 0; }
  50% { transform: translateX(100%) rotate(10deg); opacity: 0.25; }
}

@keyframes beamSweep4 {
  0%, 100% { transform: translateX(-100%) rotate(-5deg); opacity: 0; }
  50% { transform: translateX(100%) rotate(-5deg); opacity: 0.2; }
}

/* ================ 页面头部 ================ */
.ranking-header {
  position: relative;
  z-index: 10;
  padding: 2rem 1.5rem;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
}

.page-title {
  color: #fff;
  font-size: 2.5rem;
  font-weight: 800;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 1rem;
  background: linear-gradient(135deg, #ffd700 0%, #ffed4e 50%, #ffd700 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 20px rgba(255, 215, 0, 0.5));
  animation: titleGlow 3s infinite ease-in-out;
}

@keyframes titleGlow {
  0%, 100% { filter: drop-shadow(0 0 20px rgba(255, 215, 0, 0.5)); }
  50% { filter: drop-shadow(0 0 30px rgba(255, 215, 0, 0.8)); }
}

.page-title i {
  color: #ffd700;
  animation: trophyRotate 4s infinite ease-in-out;
}

@keyframes trophyRotate {
  0%, 100% { transform: rotate(0deg) scale(1); }
  25% { transform: rotate(-5deg) scale(1.1); }
  50% { transform: rotate(0deg) scale(1.2); }
  75% { transform: rotate(5deg) scale(1.1); }
}

.header-actions {
  display: flex;
  gap: 1rem;
}

.back-btn, .refresh-btn {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 0.75rem 1.5rem;
  border-radius: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}

.back-btn:hover, .refresh-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.refresh-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ================ 主要内容 ================ */
.ranking-content {
  position: relative;
  z-index: 10;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.ranking-main {
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

/* ================ 前三名展示台 ================ */
.podium-section {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.1) 0%, rgba(192, 192, 192, 0.05) 50%, rgba(205, 127, 50, 0.1) 100%);
  padding: 3rem 2rem;
  position: relative;
  overflow: hidden;
}

.podium-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle at 50% 50%, rgba(255, 215, 0, 0.1) 0%, transparent 70%);
}

.podium-container {
  display: flex;
  justify-content: center;
  align-items: end;
  gap: 2rem;
  max-width: 700px;
  margin: 0 auto;
  position: relative;
  z-index: 2;
}

.podium-item {
  text-align: center;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(15px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  padding: 2rem 1.5rem;
  position: relative;
  transition: all 0.3s ease;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.podium-item:hover {
  transform: translateY(-8px);
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3);
}

.podium-first {
  order: 2;
  margin-top: -1.5rem;
  border-color: rgba(255, 215, 0, 0.5);
  background: rgba(255, 215, 0, 0.15);
  box-shadow: 0 0 30px rgba(255, 215, 0, 0.3);
}

.podium-second {
  order: 1;
  border-color: rgba(192, 192, 192, 0.5);
  background: rgba(192, 192, 192, 0.1);
}

.podium-third {
  order: 3;
  border-color: rgba(205, 127, 50, 0.5);
  background: rgba(205, 127, 50, 0.1);
}

.podium-crown {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
  color: #8b4513;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.6);
  animation: crownFloat 3s ease-in-out infinite;
}

@keyframes crownFloat {
  0%, 100% { transform: translateX(-50%) translateY(0px) rotate(0deg); }
  50% { transform: translateX(-50%) translateY(-5px) rotate(5deg); }
}

.podium-rank {
  width: 50px;
  height: 50px;
  background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: bold;
  margin: 0 auto 1.5rem;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.podium-first .podium-rank {
  background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
  color: #8b4513;
}

.podium-second .podium-rank {
  background: linear-gradient(135deg, #c0c0c0 0%, #e5e5e5 100%);
  color: #4a4a4a;
}

.podium-third .podium-rank {
  background: linear-gradient(135deg, #cd7f32 0%, #d4922b 100%);
  color: #fff;
}

.podium-avatar {
  width: 90px;
  height: 90px;
  margin: 0 auto 1.5rem;
  position: relative;
}

.podium-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid rgba(255, 255, 255, 0.3);
  transition: all 0.3s ease;
}

.avatar-glow {
  position: absolute;
  top: -3px;
  left: -3px;
  right: -3px;
  bottom: -3px;
  border-radius: 50%;
  background: linear-gradient(45deg, #ffd700, #c0c0c0, #cd7f32, #ffd700);
  opacity: 0;
  transition: opacity 0.3s ease;
  animation: avatarGlowRotate 3s linear infinite;
  z-index: -1;
}

.podium-item:hover .avatar-glow {
  opacity: 0.6;
}

@keyframes avatarGlowRotate {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.podium-username {
  font-weight: 700;
  color: #fff;
  margin-bottom: 0.75rem;
  font-size: 1.1rem;
}

.podium-score {
  font-size: 1.8rem;
  font-weight: bold;
  color: #ffd700;
  margin-bottom: 1rem;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

/* ================ 排行榜列表 ================ */
.ranking-list {
  padding: 2.5rem;
}

.list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}

.list-header h3 {
  color: #fff;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.5rem;
  font-weight: 700;
}

.list-info {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.9rem;
}

/* ================ 加载状态 ================ */
.loading-state {
  text-align: center;
  padding: 4rem 2rem;
  color: #fff;
}

.loading-rings {
  position: relative;
  display: inline-block;
  width: 80px;
  height: 80px;
  margin-bottom: 2rem;
}

.loading-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border: 3px solid transparent;
  border-radius: 50%;
  animation: loadingRingSpin 1.5s linear infinite;
}

.loading-ring:nth-child(1) {
  border-top-color: #ffd700;
  animation-delay: 0s;
}

.loading-ring:nth-child(2) {
  border-top-color: #c0c0c0;
  animation-delay: -0.5s;
  transform: scale(0.8);
}

.loading-ring:nth-child(3) {
  border-top-color: #cd7f32;
  animation-delay: -1s;
  transform: scale(0.6);
}

@keyframes loadingRingSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-state p {
  color: rgba(255, 255, 255, 0.8);
  font-size: 1.1rem;
  margin: 0;
  animation: loadingTextPulse 2s infinite ease-in-out;
}

@keyframes loadingTextPulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

/* ================ 空状态 ================ */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: #fff;
}

.empty-animation {
  position: relative;
  display: inline-block;
  margin-bottom: 2rem;
}

.empty-animation i {
  font-size: 4rem;
  color: #ffd700;
  filter: drop-shadow(0 0 20px rgba(255, 215, 0, 0.5));
  animation: emptyTrophyFloat 3s ease-in-out infinite;
}

@keyframes emptyTrophyFloat {
  0%, 100% { transform: translateY(0px) rotate(0deg); }
  50% { transform: translateY(-10px) rotate(5deg); }
}

.empty-particles {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.empty-particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: #ffd700;
  border-radius: 50%;
  animation: emptyParticleFloat 2s infinite ease-in-out;
}

.empty-particle:nth-child(1) {
  top: -30px;
  left: -20px;
  animation-delay: 0s;
}

.empty-particle:nth-child(2) {
  top: -25px;
  right: -15px;
  animation-delay: -0.7s;
  background: #c0c0c0;
}

.empty-particle:nth-child(3) {
  bottom: -20px;
  left: -10px;
  animation-delay: -1.4s;
  background: #cd7f32;
}

@keyframes emptyParticleFloat {
  0%, 100% { transform: translateY(0px); opacity: 0.6; }
  50% { transform: translateY(-15px); opacity: 1; }
}

.empty-state p {
  color: rgba(255, 255, 255, 0.8);
  font-size: 1.1rem;
  margin: 0;
}

/* ================ 排行榜项目 ================ */
.ranking-items {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.ranking-item {
  display: flex;
  align-items: center;
  padding: 1.5rem;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.item-background {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.02) 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.ranking-item:hover .item-background {
  opacity: 1;
}

.ranking-item:hover {
  transform: translateX(8px);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.ranking-item.is-current-user {
  background: rgba(255, 215, 0, 0.1);
  border-color: rgba(255, 215, 0, 0.3);
  box-shadow: 0 0 30px rgba(255, 215, 0, 0.2);
}

.rank-number {
  width: 70px;
  text-align: center;
  margin-right: 1.5rem;
  position: relative;
  z-index: 2;
}

.rank-medal {
  font-size: 2rem;
}

.rank-gold {
  color: #ffd700;
  filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.5));
  animation: medalGlow 2s ease-in-out infinite alternate;
}

.rank-silver {
  color: #c0c0c0;
  filter: drop-shadow(0 0 10px rgba(192, 192, 192, 0.5));
}

.rank-bronze {
  color: #cd7f32;
  filter: drop-shadow(0 0 10px rgba(205, 127, 50, 0.5));
}

@keyframes medalGlow {
  0% { filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.5)); }
  100% { filter: drop-shadow(0 0 20px rgba(255, 215, 0, 0.8)); }
}

.rank-text {
  font-size: 1.5rem;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.player-avatar {
  width: 60px;
  height: 60px;
  margin-right: 1.5rem;
  position: relative;
  z-index: 2;
}

.player-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.3);
  transition: all 0.3s ease;
}

.avatar-border {
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  border-radius: 50%;
  background: linear-gradient(45deg, #ffd700, #c0c0c0, #cd7f32, #ffd700);
  opacity: 0;
  transition: opacity 0.3s ease;
  animation: avatarBorderRotate 3s linear infinite;
  z-index: -1;
}

.ranking-item:hover .avatar-border {
  opacity: 0.6;
}

@keyframes avatarBorderRotate {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.online-indicator {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 16px;
  height: 16px;
  background: #10b981;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
  animation: onlinePulse 2s infinite ease-in-out;
}

@keyframes onlinePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

.player-info {
  flex: 1;
  margin-right: 1.5rem;
  position: relative;
  z-index: 2;
}

.player-username {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.vip-icon {
  color: #ffd700;
  font-size: 0.9rem;
  filter: drop-shadow(0 0 5px rgba(255, 215, 0, 0.5));
  animation: vipGlow 2s ease-in-out infinite alternate;
}

@keyframes vipGlow {
  0% { filter: drop-shadow(0 0 5px rgba(255, 215, 0, 0.5)); }
  100% { filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.8)); }
}

.tier-badge {
  display: inline-block;
  padding: 0.3rem 0.75rem;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: bold;
  color: #fff;
  background-color: #6c757d;
  border: 1px solid #6c757d;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tier-empowered {
  background: linear-gradient(135deg, #7c3aed 0%, #8b5cf6 100%);
  border-color: #7c3aed;
  box-shadow: 0 0 15px rgba(124, 58, 237, 0.3);
}

.tier-mythic {
  background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
  border-color: #dc2626;
  box-shadow: 0 0 15px rgba(220, 38, 38, 0.3);
}

.tier-transcendent {
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
  border-color: #059669;
  box-shadow: 0 0 15px rgba(5, 150, 105, 0.3);
}

.tier-diamond {
  background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
  border-color: #4f46e5;
  box-shadow: 0 0 15px rgba(79, 70, 229, 0.3);
}

.tier-platinum {
  background: linear-gradient(135deg, #e5e7eb 0%, #f3f4f6 100%);
  border-color: #d1d5db;
  color: #374151;
  box-shadow: 0 0 15px rgba(229, 231, 235, 0.3);
}

.tier-gold {
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
  border-color: #f59e0b;
  color: #92400e;
  box-shadow: 0 0 15px rgba(251, 191, 36, 0.3);
}

.tier-silver {
  background: linear-gradient(135deg, #9ca3af 0%, #6b7280 100%);
  border-color: #6b7280;
  box-shadow: 0 0 15px rgba(156, 163, 175, 0.3);
}

.tier-bronze {
  background: linear-gradient(135deg, #a16207 0%, #92400e 100%);
  border-color: #92400e;
  box-shadow: 0 0 15px rgba(161, 98, 7, 0.3);
}

.tier-iron {
  background: linear-gradient(135deg, #4b5563 0%, #374151 100%);
  border-color: #374151;
  box-shadow: 0 0 15px rgba(75, 85, 99, 0.3);
}

.player-stats {
  display: flex;
  gap: 2rem;
  margin-right: 1.5rem;
  position: relative;
  z-index: 2;
}

.stat-item {
  text-align: center;
}

.stat-label {
  display: block;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 1.1rem;
  font-weight: bold;
  color: #fff;
}

.rank-change {
  width: 80px;
  text-align: center;
  position: relative;
  z-index: 2;
}

.rank-up {
  color: #10b981;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
}

.rank-down {
  color: #ef4444;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
}

.rank-same {
  color: rgba(255, 255, 255, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ================ 分页器 ================ */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 2.5rem;
  padding-top: 2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.pagination-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  padding: 0.75rem 1.5rem;
  border-radius: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}

.pagination-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.pagination-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pagination-pages {
  display: flex;
  gap: 0.5rem;
}

.pagination-page {
  width: 45px;
  height: 45px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}

.pagination-page:hover:not(:disabled) {
  border-color: rgba(255, 215, 0, 0.5);
  color: #ffd700;
  transform: scale(1.1);
}

.pagination-page.active {
  background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
  border-color: #ffd700;
  color: #8b4513;
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.4);
}

/* ================ 响应式设计 ================ */
@media (max-width: 1024px) {
  .ranking-container {
    padding: 0;
  }
  
  .ranking-content {
    padding: 1.5rem 1rem;
  }
  
  .podium-container {
    gap: 1.5rem;
  }
  
  .player-stats {
    gap: 1.5rem;
  }
}

@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    gap: 1.5rem;
    text-align: center;
  }

  .page-title {
    font-size: 2rem;
  }

  .podium-container {
    flex-direction: column;
    align-items: center;
    gap: 1rem;
  }

  .podium-item {
    width: 100%;
    max-width: 300px;
    margin-top: 0 !important;
  }

  .ranking-item {
    flex-direction: column;
    text-align: center;
    gap: 1rem;
    padding: 1.5rem 1rem;
  }

  .player-stats {
    gap: 1rem;
    justify-content: center;
  }

  .list-header {
    flex-direction: column;
    gap: 0.75rem;
    text-align: center;
  }

  .pagination {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  
  .pagination-btn {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
  }
}

@media (max-width: 480px) {
  .ranking-header {
    padding: 1.5rem 1rem;
  }
  
  .page-title {
    font-size: 1.8rem;
  }
  
  .ranking-content {
    padding: 1rem 0.5rem;
  }
  
  .ranking-list {
    padding: 1.5rem 1rem;
  }
  
  .podium-item {
    padding: 1.5rem 1rem;
  }
  
  .ranking-item {
    padding: 1rem;
  }
  
  .player-stats {
    gap: 0.75rem;
  }
  
  .stat-item {
    font-size: 0.9rem;
  }
}

/* ================ 深色模式增强 ================ */
@media (prefers-color-scheme: dark) {
  .ranking-container {
    background: linear-gradient(135deg, #0f0a23 0%, #1a0f3a 25%, #2d1b4e 50%, #1e0f3f 75%, #0a0519 100%);
  }
}

/* ================ 减少动画偏好 ================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ================ 高对比度模式 ================ */
@media (prefers-contrast: high) {
  .ranking-container {
    background: linear-gradient(135deg, #000 0%, #1a1a1a 100%);
  }
  
  .ranking-item,
  .podium-item {
    border-color: rgba(255, 255, 255, 0.4);
  }
  
  .pagination-btn,
  .back-btn,
  .refresh-btn {
    border-color: rgba(255, 255, 255, 0.5);
  }
}

/* ================ 滚动条样式 ================ */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, #e6c200 0%, #e6d445 100%);
}

/* ================ 选择文本样式 ================ */
::selection {
  background: rgba(255, 215, 0, 0.3);
  color: #fff;
}

::-moz-selection {
  background: rgba(255, 215, 0, 0.3);
  color: #fff;
}

/* ================ 焦点可见性 ================ */
.back-btn:focus-visible,
.refresh-btn:focus-visible,
.pagination-btn:focus-visible,
.pagination-page:focus-visible {
  outline: 2px solid #ffd700;
  outline-offset: 2px;
}
</style>
